<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateClientContractsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('client_contracts', function (Blueprint $table) {
            $table->increments('contract_id');
            $table->string('contract_code')->default('')->comment('合同编号(规则:CL-YYYYMMDD-XXX)');
            $table->bigInteger('client_id')->comment('客户ID(关联client表)');
            $table->string('contract_name')->default('')->comment('合同名称');
            $table->enum('contract_type')->comment('合同类型');
            $table->date('sign_date')->comment('签订日期');
            $table->date('effective_date')->comment('生效日期');
            $table->date('expiry_date')->nullable()->comment('终止日期(空表示无固定期限)');
            $table->decimal('total_amount')->comment('合同总金额');
            $table->char('currency')->default('CNY')->nullable()->comment('结算币种');
            $table->text('payment_terms')->nullable()->comment('付款条件说明');
            $table->enum('contract_status')->default('DRAFT')->nullable()->comment('合同状态');
            $table->string('attachment_path')->nullable()->comment('电子合同附件路径');
            $table->string('created_by')->nullable()->comment('创建人');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('client_contracts');
    }
}
